import { _decorator, Component, Node } from 'cc';
import { resourceManager } from './ResourceManager';
import { AudioClip } from 'cc';
import { GameConfig } from '../GameConfig';
import { AudioMgr } from './AudioMgr';
const { ccclass, property } = _decorator;

@ccclass('AudioManager')
export class AudioManager {

    playEffect(url: string) {
        resourceManager.loadAssetInBundle(url, AudioClip, GameConfig.gameName).then((res: AudioClip) => {
            res && AudioMgr.inst.playOneShot(res, 1);
        });
    }

    playBgm(url: string) {
        resourceManager.loadAssetInBundle(url, AudioClip, GameConfig.gameName).then((res: AudioClip) => {
            res && AudioMgr.inst.play(res, 1);
        });
    }

    stop() {
        AudioMgr.inst.stop();
    }

    pause() {
        AudioMgr.inst.pause();
    }

    resume() {
        AudioMgr.inst.resume();
    }
}

export const audioManager = new AudioManager();

